import pandas as pd
import sklearn.ensemble as ensemble
from sklearn.model_selection import train_test_split
import joblib
import sys
import numpy as np
import json
import sklearn.metrics as metrics

# 读取训练集
df = pd.read_csv("train_10000.csv")
df = df.fillna(df.mean())

# 取出标签和数据
y = df["label"]
x = df.iloc[:, 1:-1]

# 划分训练集
seed = 5
x_train, x_test, y_train, y_test = train_test_split(x, y, random_state=seed)
rfc2 = ensemble.RandomForestClassifier(criterion="entropy", max_depth=14, min_samples_split=4, n_estimators=40)
rfc2.fit(x_train, y_train)

# 保存模型
joblib.dump(rfc2, 'FR_model2.joblib')

